import type {
  User,
  codeType,
  UserInfo,
  PatientList,
  Patient
} from '@/types/user'
import { request } from '@/utils/request'

export const login = (mobile: string, password: string) => {
  return request<User>('/login/password', 'POST', { mobile, password })
}
// 定义发送验证码的接口
export const sendMobileCode = (mobile: string, type: codeType) => {
  return request('/code', 'GET', { mobile, type })
}
// 验证码登录
export const loginByMobile = (mobile: string, code: string) => {
  return request<User>('/login', 'post', { mobile, code })
}
// 获取个人信息
export const getUserInfo = () => {
  return request<UserInfo>('/patient/myUser')
}
// 患者列表
export const getPatientList = () => {
  return request<PatientList>('/patient/mylist')
}
// 添加患者
export const addPatient = (patient: Patient) =>
  request('/patient/add', 'POST', patient)

// 修改
export const editPatient = (patient: Patient) =>
  request('/patient/update', 'PUT', patient)
// 删除患者信息
export const delPatient = (id: string) =>
  request(`/patient/del/${id}`, 'DELETE')
